// 编程实现数组和对象的深拷贝

let deepClone = data => {
    let result = []
    data.forEach((value, i) => {
        if(typeof(value) === 'object'){  
            result[i] = deepClone(value)
        }
        else 
            result[i] = value
    })
    return result
}

//浅拷贝
let arr2 = [4, 5, 7, [1, 2, 3]]
let arr3 = deepClone(arr2)
arr2[3][1] = 5
console.log(arr3[3][1])

//数组遍历方法举例
let arr = [1, 2, 3, 4, 5]
let flag = arr.some(function (value) {
    console.log(value)
    return value >= 7
})
console.log(flag)

let sum = arr.reduce(function (prev, curr, index, array) {
    console.log(prev, curr, index, array)
    return prev + curr
}, 0)
console.log(sum)